import { alias } from './alias.config';
import { defineConfig } from 'vite';
import path from 'path';
import react from '@vitejs/plugin-react';       // React 热更新和 JSX 支持
import svgr from 'vite-plugin-svgr';            // SVG 转 React 组件
import { viteStaticCopy } from 'vite-plugin-static-copy'; // 静态资源复制

export default defineConfig({
  build: {
    rollupOptions: {
      input: {
        index: path.resolve(__dirname, '../src/renderer/index.html'),
      },
      output: {
        dir: '.vite/renderer/main_window',
      },
    },
  },
  plugins: [
    react(),
    svgr({ include: '**/*.svg' }),  // 处理所有 SVG 文件
    // 复制静态资源到打包目录
    viteStaticCopy({
      targets: [
        {
          src: ['../../assets/fonts'],  // 源路径
          dest: path.resolve(__dirname, '../.vite/renderer/assets'),
        },
      ],
    }),
  ],
  resolve: {
    alias,
    extensions: ['.js', '.ts', '.jsx', '.tsx', '.css'],
  },
  root: path.resolve(__dirname, '../src/renderer'),
});
